import { ElMessageBox } from "element-plus";

/**
 * 封装EL确认弹窗
 * @param {string} message 弹窗内容
 * @param {string} type 弹窗类型，默认 'warning'
 * @param {string} title 弹窗标题，默认 '注意'
 * @param {boolean} draggable 是否可拖动弹窗，默认 true
 * @param {string} confirmButtonLabel 确定按钮文字，默认 '确认，我很坚定'
 * @param {string} cancelButtonLabel 取消按钮文字，默认 '取消，我后悔了'
 * @return {Promise<boolean>} true 确认，false 取消
 */
export function elConfirm(message,
                          type = 'warning',
                          title = '注意',
                          draggable = true,
                          confirmButtonLabel = '确认，我很坚定',
                          cancelButtonLabel = '取消，我后悔了') {
    return ElMessageBox.confirm(message, title,
        {
            confirmButtonText: confirmButtonLabel,
            cancelButtonText: cancelButtonLabel,
            type: type,
            draggable: draggable
        }).then(() => true).catch(() => false);
}